package work20241209.a_hashCode;

/**
 * @author zdl
 * @date 2024/12/9
 */
class Animal{
    long id;
    String num;
    String name;

    public Animal(long id, String num, String name) {
        this.id = id;
        this.num = num;
        this.name = name;
    }
}
public class Demo {
    public static void main(String[] args) {
        Object obj = new Object();
        Object obj1 = new Object();
        System.out.println(obj.hashCode()); //十六进制转为十进制值
        String str1 = new String("abc");
        String str2 = new String("abc");
        System.out.println(str1.hashCode() == str2.hashCode()); //true
        Integer integer = new Integer(2);
        Integer integer1 = new Integer(2);
        System.out.println(integer1.hashCode() == integer.hashCode()); //true
        String str3 = new String("ABC");
        System.out.println("-------123-------");
        System.out.println(str1.equals(str2)); //true
        System.out.println(str1.equals(str3)); //false
        System.out.println(obj.equals(obj1)); //false

        Animal a1 = new Animal(1,"222","jack");
        Animal a2 = new Animal(1,"222","jack");
        System.out.println(a1.equals(a2));//false
    }
}
